<!DOCTYPE html>
<html lang="en">
<head>
<title>学而阅读-忘记密码</title> <#include "/common/head.ftl"/>
<link rel="stylesheet" href="${path}/css/pwdForget.css" />
<script type="text/javascript">
	$(document).ready(function() {

	});
	function submitForm() {
		var mob = /^1[3|4|5|6|7|8|9][0-9]\d{4,8}$/;
		var userAccount = $("#userAccount").val();
		var userPassword = $("#userPassword").val();
		var userAgainPassword = $("#userAgainPassword").val();
		var userValidateCode = $("#userValidateCode").val();
		if (userAccount) {
			if (!mob.exec(userAccount)) {
				$("#validInfo").html("手机号码格式不对！");
				$("#userAccount").attr('value', '');
				$("#userAccount").focus();
				return false;
			} else {
				if (userPassword) {
					if ((userPassword.length < 6) || (userPassword.length > 20)) {
						$("#validInfo").html("密码长度应为6-20位数！");
						$("#userPassword").focus();
					} else {
						if (userPassword != userAgainPassword) {
							$("#validInfo").html("两次密码输入不一致！");
							$("#userPassword").attr('value', '');
							$("#userAgainPassword").attr('value', '');
							$("#userPassword").focus();
						} else {
							if (userValidateCode) {
								$("#validInfo").html("");
								$.post($("#form1").attr("action"), $("#form1")
										.serialize(), function(data) {
									var result = $.parseJSON(data);
									if (result.code == 0) {
										window.location.href = result.url;
									} else {
										$("#validInfo").html(result.message);
									}
								});
							} else {
								$("#validInfo").html("请输入验证码！");
								$("#userValidateCode").focus();
							}

						}
					}
				} else {
					$("#validInfo").html("请输入密码！");
					$("#userPassword").focus();
				}
			}
		} else {
			$("#validInfo").html("请输入手机号码！");
			$("#userAccount").focus();
		}

	}
	function sendSMS() {
		var mob = /^1[3|4|5|6|7|8|9][0-9]\d{4,8}$/;
		var userAccount = $("#userAccount").val();
		if (userAccount) {
			if (!mob.exec(userAccount)) {
				$("#validInfo").html("手机号码格式不对！");
				$("#userAccount").attr('value', '');
				$("#userAccount").focus();
				return false;
			} else {
				$("#validInfo").html("");
				$.post("${path}/user/sendForgetSMS", "userAccount="
						+ userAccount, function(data) {
					var result = $.parseJSON(data);
					if (result.code == 0) {
						$("#send").attr("href", "javascript:void( );");
						countdownSend(60);
					} else {
						$("#validInfo").html(result.message);
					}
				});
			}
		} else {
			$("#validInfo").html("请输入手机号码！");
			$("#userAccount").focus();
		}
	}
	function countdownSend(id) {
		id = id - 1;
		if (id > 0) {
			$("#send").html(id);
			setTimeout("countdownSend(" + id + ")", 1000);
		} else {
			$("#send").html("重新获取验证码");
			$("#send").attr("href", "javascript:sendSMS();");
			bindSms();
		}
	}
</script>
</head>
<body>
	<#include "/common/header.ftl"/> <#include "/common/nav.ftl"/>
	<!-- 手机找回密码 -->
	<div class="findPsd">
		<form id="form1" name="form1" action="${path}/user/pwdForgetSave"
			method="post">
			<div class="fp-head">
				<div class="reg-head-title f42">手机找回密码</div>
				<div class="tip f36">已绑定手机的用户，填写绑定的手机号获取短信验证码，输入新密码完成密码找回</div>
			</div>
			<div class="fp-form">
				<div class="line">
					<div class="input">
						<input type="text" name="userAccount" id="userAccount"
							class="username" placeholder="请输入手机号码">
					</div>
				</div>
				<div class="line">
					<div class="input inp-exp fl">
						<input type="text" name="userValidateCode" id="userValidateCode"
							class="vcode" placeholder="输入验证码" />
					</div>
					<a class="get-vcode f40 cfff tc dlb fr"
						href="javascript:sendSMS();" id="send">获取验证码</a>
				</div>
				<div class="line">
					<div class="input">
						<input type="password" name="userPassword" id="userPassword"
							class="psd" placeholder="重置账号密码" />
					</div>
				</div>
				<div class="line">
					<div class="input">
						<input type="password" name="userAgainPassword"
							id="userAgainPassword" class="psd-again" placeholder="确认账号密码" />
					</div>
				</div>
				<div class="error-info">
					<span id="validInfo"></span>
				</div>
				<div class="btn-save">
					<input type="button" onclick="submitForm();" value="确认重置" />
				</div>
			</div>
		</form>
	</div>
	<#include "/common/footer.ftl"/>
</body>
</html>